<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String contextPath = request.getContextPath();
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>天下信用-首页</title>
</head>
<body>
	主程序
	<img id="qrcode" src=""></img>
</body>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script>
!function(){
	 var k = uuid();
	
	 function uuid() {
		 var uuid='';
		 $.ajax({
				url:'<%= contextPath%>/qrLogin',
				type:'POST',
				async:false,
				success:function(data){
					var imgSrc="data:image/png;base64,"+data.base64;
					uuid = data.uuid;
					$("#qrcode").attr("src",imgSrc);
					$("#qrcode").attr("uuid",uuid);
				}
			});
		    return uuid;
	}
	var evtSource = new EventSource("<%= contextPath%>/waitQrLogin/"+k);
	evtSource.addEventListener("ready", function (e) {
		//close后就不自动重连了，否则就算服务器端对应的方法走完了，还会重新建立连接额
		evtSource.close();
		location.href = "www.baidu.com";
    }, false );
}();
</script>

</html>